package vn.vfriends.soffice.facade;

import java.util.List;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import vn.vfriends.soffice.entity.Menu;
import vn.vfriends.soffice.entity.Permission;

/**
 *
 * @author chaungoctuan@gmail.com
 */
@Stateless
@LocalBean
public class PermissionFacade extends AbstractFacade<Permission> {

    @PersistenceContext(unitName = "sOfficePU")
    private EntityManager em;

    public PermissionFacade() {
        super(Permission.class);
    }
    
    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public List<Permission> findPermissionsByMenu(Menu menu) {
        Query query = em.createNamedQuery("Permission.findByMenu", Menu.class);
        query.setParameter("menu", menu);
        return query.getResultList();
    }
}
